<?php
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Auth;
use Closure;

// 前台登录验证中间件
class AuthMember{
    public function handle($request, Closure $next)
    {
        if(Auth::guard('member')->guest()){
            if($request->ajax()){
                $response = array('code'=>401,'msg'=>'您没有登录请登录');
                return response(json_encode($response),200);
            }
            return redirect()->guest('/home/login');
        }
        return $next($request);
    }
}
